/*
 * @Author: yanjikun
 * @Date: 2022-03-24 10:38:21
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-04-22 11:58:44
 * @Description: file content
 */
import type { TableColumnType } from 'ant-design-vue'
import { VNode } from 'vue'
import { ActionItem } from './tableAction'

export type ColumnParams<T = any> = {
  record: T
  text: string
  index: number
  column: TableColumn<T>
}

/**表格单元格配置 */
export interface TableColumn<T = Recordable> extends Omit<TableColumnType<T>, 'dataIndex' | 'key'> {
  title: string
  dataIndex: keyof T | '$action'
  key?: keyof T | '$action'
  width?: number
  /** 在 Table 中不展示此列 */
  hideInTable?: boolean
  bodyCell?: (params: ColumnParams<T>) => VNode | string
  headerCell?: (params: ColumnParams<T>) => VNode | string
  actions?: (params: ColumnParams<T>) => ActionItem[]
}
